package com.newtouch.bxzs.enterprise.controller;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.newtouch.bxzs.common.base.response.BaseResponse;
import com.newtouch.bxzs.common.base.response.RespGenerator;
import com.newtouch.bxzs.enterprise.config.MyLog;
import com.newtouch.bxzs.enterprise.model.bo.CustomerFamilyRelationshipBO;
import com.newtouch.bxzs.enterprise.model.vo.CustomerFamilyVO;
import com.newtouch.bxzs.enterprise.model.vo.CustomerFamilyRelationshipVO;
import com.newtouch.bxzs.enterprise.service.CustomerFamilyRelationshipService;

import cn.hutool.core.collection.CollectionUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 客户家庭关系普
 *
 * <p>
 * <b>History:</b>
 * <table border="1">
 * <tr>
 * <th>Date</th>
 * <th>Operator</th>
 * <th>Memo</th>
 * </tr>
 * <tr>
 * <td>2021/3/19 14:50</td>
 * <td>chenfugui</td>
 * <td>Create</td>
 * </tr>
 * </table>
 *
 * @author chenfugui
 * @version 1.0.0
 * @since 1.0.0
 */

@Api(tags = "家庭关系普")
@RestController
@RequestMapping(value = "/customerFamilyRelationshipController")
@SuppressWarnings("unchecked")
public class CustomerFamilyRelationshipController {
	@Autowired
	private CustomerFamilyRelationshipService customerFamilyRelationshipService;

	/** 静态变量：系统日志 */
	private static final Log logger = LogFactory.getLog(CustomerFamilyRelationshipController.class);

	@ApiOperation(value = "获取个人客户家庭关系列表信息")
	@PostMapping("/getCustomerFamilyRelationshipList")
	@MyLog(systemFunctionName = "个人客户管理", systemFunctionUrl = "/customerFamilyRelationshipController/getCustomerFamilyRelationshipList", userOperationType = 4, userOperationSummary = "获取个人客户家庭关系列表信息")
	public BaseResponse<CustomerFamilyRelationshipBO> getCustomerFamilyRelationshipList(
			@RequestBody CustomerFamilyRelationshipVO familyRelationshipVO) {
		logger.info("获取个人客户家庭关系列表信息");
		return RespGenerator
				.returnOK(customerFamilyRelationshipService.getCustomerFamilyRelationshipList(familyRelationshipVO));
	}


	@ApiOperation(value = "增加或者修改家庭关系信息")
	@PostMapping("/modifyCustomerFamilyRelationship")
	@MyLog(systemFunctionName = "个人客户管理", systemFunctionUrl = "/customerFamilyRelationshipController/modifyCustomerFamilyRelationship", userOperationType = 5, userOperationSummary = "增加或者修改家庭关系信息")
	public BaseResponse<Object> modifyCustomerFamilyRelationship(@RequestBody CustomerFamilyVO customerFamilyVO) {
		logger.info("增加或者修改家庭关系信息");
		return RespGenerator
				.returnOK(customerFamilyRelationshipService.modifyCustomerFamilyRelationship(customerFamilyVO));
	}

	@ApiOperation(value = "删除家庭关系信息")
	@PostMapping("/deleteCustomerFamilyRelationship")
	@MyLog(systemFunctionName = "个人客户管理", systemFunctionUrl = "/customerFamilyRelationshipController/deleteCustomerFamilyRelationship", userOperationType = 3, userOperationSummary = "删除家庭关系信息")
	public BaseResponse<Object> deleteCustomerFamilyRelationship(@RequestBody CustomerFamilyVO customerFamilyVO) {
		logger.info("删除家庭关系信息");
		return RespGenerator.returnOK(customerFamilyRelationshipService.deleteCustomerFamilyRelationship(
				customerFamilyVO.getFamilyRelationshipId(), customerFamilyVO.getDataSource()));
	}

	/**
	 * 获取对端客户家庭关系信息接口
	 *
	 * @param familyRelationshipVO
	 *            客户信息VO
	 * @return 客户家庭关系信息返回BO
	 */
	@PostMapping("/acceptionCustomerFamilyRelationship")
	public List<CustomerFamilyRelationshipBO> acceptionCustomerFamilyRelationship(
			@RequestBody CustomerFamilyRelationshipVO familyRelationshipVO) {
		logger.info("获取对端客户家庭关系信息");
		return customerFamilyRelationshipService.acceptionCustomerFamilyRelationship(familyRelationshipVO);
	}

}
